const express = require('express');
const cors= require('cors');
// const bodyParser = require('body-parser');

const server= express();

// 引入中间件,bodyParser和express用其中一个就可以了，两者功能差不多，body-parser是第三方中间件 
// server.use(bodyParser.urlencoded({extended:false}));
// server.use(bodyParser.json());
server.use(cors())
server.use(express.urlencoded({extende:false}))
server.use(express.json())


//静态资源服务器
server.use(express.static('public'))


// server.use(function (req, res, next) {
//     if (!req.user) return next(createError(401, 'Please login to view this page.'))
//     next()
//   })

server.use('/account',require('./routers/account.js'))
server.use('/cart',require('./routers/carts.js'))
server.use('/goods',require('./routers/goods.js'))



server.listen(8088,()=>{
    console.log('服务器启动成功，监听端口8088');
})



